import { Controller, Get, Query, ParseIntPipe, Post, Body, Inject } from "@nestjs/common";
import { TestService } from "./test.service";
import { Serialize } from "../decorators/serialize.decorator";
import { TestSerializeResDto } from "./dto/test-serialize-res-dto";
import { TestSerializeReqDto } from "./dto/test-serialize-req-dto";
import { CACHE_MANAGER } from "@nestjs/cache-manager";
import type { Cache } from "cache-manager";

@Controller("test")
export class TestController {
  constructor(
    private readonly testService: TestService,
    @Inject(CACHE_MANAGER) private cacheManager: Cache,
  ) {}

  @Get("/range")
  getRange(@Query("num", ParseIntPipe) num: number) {
    return this.testService.getRange(num);
  }

  @Post("/serialize")
  @Serialize(TestSerializeResDto)
  testSerialize(@Body() dto: TestSerializeReqDto) {
    console.log("dto ————》", dto);
    return dto;
  }
}
